<?php

namespace Trawind\Events\Subscribers\Inventory\Inventory;

use Trawind\Events\Events\Sale\Cabinet\DeleteCabinetEvent;
use Trawind\Events\Events\Sale\Cabinet\StoreCabinetEvent;
use Trawind\Extension\Models\Deploy\BusinessType;

class SizeSubscriber
{
    private $businessType = \Trawind\Basics\Enums\BusinessType::INVENTORY_INVENTORY_SIZE;

    public function storeCabinet($event)
    {
        $repository = BusinessType::getEloquentById($this->businessType);
        $repository->callback($event->payload, StoreCabinetEvent::class);
    }

    public function deleteCabinet($event)
    {
        $repository = BusinessType::getEloquentById($this->businessType);
        $repository->callback($event->payload, DeleteCabinetEvent::class);
    }

    /**
     *
     * @param  \Illuminate\Events\Dispatcher  $events
     */
    public function subscribe($events)
    {
        $events->listen(
            StoreCabinetEvent::class,
            static::class . '@storeCabinet'
        );

//        $events->listen(
//            DeleteCabinetEvent::class,
//            static::class . '@deleteCabinet'
//        );
    }
}
